package jgcp.common;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
 * 
 * @Date 31/05/2009
 * @author Jie Zhao (288654)
 * @version 1.0
 */
public class TaskStore {
	private List<Task> store = new ArrayList<Task>();
	private static TaskStore instance = new TaskStore();
	private TaskStore(){}
	public static TaskStore getInstance()
	{
		return instance;
	}
	
	public void store(Task task)
	{
		store.add(task);
	}
	public Task retrieve(int taskId)
	{
		for(Iterator<Task> i=store.iterator();i.hasNext();)
		{
			Task t = i.next();
			if(t.getTaskid() == taskId)
			{
				return t;
			}
		}
		return null;
	}
	public List<Integer> getStoreList()
	{
		List<Integer> result = new ArrayList<Integer>();
		for(Task t:store)
		{
			result.add(t.getTaskid());
		}
		return result;
	}
}
